package 力扣.动态规划;

import java.util.Arrays;
import java.util.List;

public class 杨辉三角2 {
    public static void main(String[] args) {
        System.out.println(getRow(4));
    }

    public static List<Integer> getRow(int rowIndex) {
        Integer[][] ints = new Integer[rowIndex + 1][rowIndex + 1];
        for (int i = 0; i < rowIndex + 1; i++) {
            for (int j = 0; j < rowIndex + 1; j++) {
                ints[i][j]=1;
            }
        }
        for (int i = 2; i < rowIndex+1; i++) {
            for (int j = 1; j < i; j++) {
                ints[i][j]=ints[i-1][j-1]+ints[i-1][j];
            }
        }
        return Arrays.asList(ints[rowIndex]);
    }
}
